public class Solution {

    public static void merge(int A[], int m, int B[], int n) {
        int ap = 0, bp = 0, cp = 0; // 分别指向A 数组 和 B数组
        int[] C = new int[m+n];
        while(ap < m && bp < n){
            if(A[ap] < B[bp]){
                C[cp] = A[ap];
                ap++;
            } else{
                C[cp] = B[bp];
                bp++;
            }
            cp++;
        }
        if(ap == m){
            for(int j = bp; j < n; j++){
                C[cp++] = B[j];
            }
        }
        if(bp == B.length){
            for(int j = ap; j < m; j++){
                C[cp++] = A[j];
            }
        }
        for(int k = 0; k < m + n; k++){
            A[k] = C[k];
        }
    }
}